home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / unix / arcunx11 / arc.sh1 / arcdel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-04-01  |  2.7 KB  |  86 lines

  1. /*
  2.  *    arcdel.c    1.1
  3.  *
  4.  *    Author: Thom Henderson
  5.  *    Original System V port: Mike Stump
  6.  *    Enhancements, Bug fixes, and cleanup: Chris Seaman
  7.  *    Date: Fri Mar 20 09:57:02 1987
  8.  *    Last Mod.    3/21/87
  9.  *
  10.  */
  11.  
  12. /*
  13.  * ARC - Archive utility - ARCDEL
  14.  * 
  15.  * Version 2.09, created on 02/03/86 at 22:53:27
  16.  * 
  17.  * (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  18.  * 
  19.  *     Description:
  20.  *          This file contains the routines used to delete entries
  21.  *          in an archive.
  22.  */
  23.  
  24. #include "arc.h"
  25.  
  26. INT delarc(argc,argv)                  /* remove files from archive */
  27. INT argc;                              /* number of arguments */
  28. char *argv[];                          /* pointers to arguments */
  29. {
  30.     struct heads hdr;                  /* header data */
  31.     INT del;                           /* true to delete a file */
  32.     INT did[MAXARG];                   /* true when argument used */
  33.     INT n;                             /* index */
  34.  
  35.     if (!argc)                         /* she must specify which */
  36.         abort("You must tell me which files to delete!");
  37.  
  38.     for (n=0; n<argc; n++)             /* for each argument */
  39.         did[n] = 0;                    /* reset usage flag */
  40.     rempath(argc,argv);                /* strip off paths */
  41.  
  42.     openarc(1);                        /* open archive for changes */
  43.  
  44.     while (readhdr(&hdr,arc))          /* while more entries in archive */
  45.     {
  46.         del = 0;                       /* reset delete flag */
  47.         for (n=0; n<argc; n++)         /* for each template given */
  48.         {
  49.             if (match(hdr.name,argv[n]))
  50.             {
  51.                 del = 1;               /* turn on delete flag */
  52.                 did[n] = 1;            /* turn on usage flag */
  53.                 break;                 /* stop looking */
  54.             }
  55.         }
  56.  
  57.         if (del)                       /* skip over unwanted files */
  58.         {
  59.             fseek(arc,hdr.size,1);
  60.             if (note)
  61.                 printf("Deleting file: %s\n",hdr.name);
  62.         }
  63.         else                           /* else copy over file data */
  64.         {
  65.             writehdr(&hdr,new);        /* write out header and file */
  66.             filecopy(arc,new,hdr.size);
  67.         }
  68.     }
  69.  
  70.     hdrver = 0;                        /* special end of archive type */
  71.     writehdr(&hdr,new);                /* write out archive end marker */
  72.     closearc(1);                       /* close archive after changes */
  73.  
  74.     if (note)
  75.     {
  76.         for (n=0; n<argc; n++)         /* report unused arguments */
  77.         {
  78.             if (!did[n])
  79.             {
  80.                 printf("File not found: %s\n",argv[n]);
  81.                 nerrs++;
  82.             }
  83.         }
  84.     }
  85. }
  86.